<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Schools Management System</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
<script>

function deletevari()
{
<?php
include_once '../Login/databaseconnection.php';
if(!loggedin())
{
	require_once '../index.php';
}
   
   else
   {
   $Competition_Id=$_POST['Competition_Id'];
   $School_Id=$_POST['School_Id'];
	  $Date=$_POST['Date'];
  
   if($Competition_Id=="Select One"||$School_Id=="Select One"||$Date=="Select One")
	   {
		   $_SESSION['errorin']="Please select the Competition_Id,School_Id and Date!";
   
	   }  
 if($Competition_Id!="Select One"&&$School_Id!="Select One"&&$Date!="Select One")
	   {
   ?>
var r=confirm("Are you sure to delete this?");

if (r==true)
  {
  <?php
	
	   $result=mysql_query("SELECT * FROM competition WHERE Competition_Id='$Competition_Id' AND School_Id='$School_Id' AND Date='$Date'");
	  
	   if(mysql_num_rows($result)==0)
   {

	   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   else
   {
		  $del=mysql_query("DELETE FROM competition WHERE Competition_Id='$Competition_Id' AND School_Id='$School_Id' AND Date='$Date'");
	if($del)
  {
$_SESSION['error']="This record is successfully deleted!";
 
  }

  if(!$del)
  {
 $_SESSION['error']="Sorry unable to delete this record!";


  }
  }
  }
 
  ?>

  }
if(r==false)
  {
  alert("You pressed Cancel!");
  }


}
<?php
}
?>
</script>

</head>
<body>
 <?php
require_once '../Login/databaseconnection.php';
if(!loggedin())
{
require_once '../index.php';

}
   
   else
   {
   
	  
  ?>
<div id="wrap">

<div id="header"><table width="1239" border="0">
  <tr>
    <td width="866" height="119" rowspan="2"><h1 class="heaaderte"><font color="#996699" style="text-shadow:#969" size="+6">Schools Management System</font></h1></td>
    <td width="110" height="88">&nbsp;</td>
    <td width="161">&nbsp;</td>
    <td width="84">&nbsp;</td>
  </tr>
  <tr>
    <td height="21">&nbsp;</td>
    <td>
	<?Php
	//$First_Name=$_SESSION['First_Name'];
    //$_SESSION['Last_Name']=$Last_Name;
	  if(isset($_SESSION['First_Name']))
	  
{
      echo "Hi,". $_SESSION['First_Name']." ".$_SESSION['Last_Name'];
}
?></td>
    <td><a href="../Logout.php" class="logout">Logout</a></td>
  </tr>
  </table>
</div>

<div id="menu1_bg">
		<div id="menu1">
			
	
	
				<ul>
				<li><a href="../index.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Home</font></a></li>
				<li><a href="../Schools/Schools.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Schools</font></a></li>
				<li><a href="../Teachers/teachers.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Teachers</font></a></li>
				<li><a href="../Lab/Labs.php""><font color="#CCCC66" style="text-shadow:#969" size="+1">Labs</font></a></li>
				<li><a href="../Resources/Resources.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Resources</font></a></li>
                <li><a href="#"><font color="#CCCC66" style="text-shadow:#969" size="+1">Resource Team</font></a></li>
                         <li><a href="../Programmes/Programmes.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Programmes</font></a></li>
                                  <li><a href="Competition.php" class="active"><font color="#CCCC66" style="text-shadow:#969" size="+1">Competitions</font></a></li>
                 <li></li>
			</ul>
	</div>
  </div>
<div class="left">
  
<div class="articles">
<form action="#" method="POST">
  <table width="541" border="0">
    <tr>
      <th height="29" colspan="5"  scope="row">
      <?php
      if(isset($_POST['Delete']))
{
	if(isset($_SESSION['errorin']))
	{
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['error']))
	{
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errornorow']))
	{
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
}   
?>
</th>
      </tr>
    <tr>
      <th width="40" height="29"  scope="row">&nbsp;</th>
      <th width="110" height="29"  scope="row">Competition Id:</th>
      <td colspan="3">
      
      <select name="Competition_Id" id="select">
	   <?php
	  
	  if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$Competition_Id.'">'.$Competition_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	  $com=mysql_query("SELECT DISTINCT(Competition_Id) FROM competition");
	  
  while($row=mysql_fetch_array($com))
  {
	 $Competition_Id=$row['Competition_Id'];

	  echo '<option value="'.$Competition_Id.'">'.$Competition_Id.'</option>';
  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <th height="30" scope="row">&nbsp;</th>
      <th height="30" scope="row">School Id:</th>
      <td colspan="3"> <select name="School_Id" id="select">
	  <?php
	  
	  if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	  $com=mysql_query("SELECT DISTINCT(School_Id) FROM competition");
	  
  while($row=mysql_fetch_array($com))
  {
	 $Sch_Id=$row['School_Id'];

	  echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <th height="23" scope="row">&nbsp;</th>
      <th scope="row">Date:</th>
      <td colspan="3"><select name="Date" id="select">
	 <?php
	  
	  if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$Date.'">'.$Date.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	  $com=mysql_query("SELECT DISTINCT(Date) FROM competition");
	  
  while($row=mysql_fetch_array($com))
  {
	 $Date=$row['Date'];

	  echo '<option value="'.$Date.'">'.$Date.'</option>';
  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <th height="23" scope="row">&nbsp;</th>
      <th scope="row">&nbsp;</th>
      <td width="88">&nbsp;</td>
      <td width="136"><a href="DelCom.php">Reset</a>|
        <input name="Delete" align="middle" type="submit" value="Delete" onclick="deletevari()" /></td>
      <td width="145">&nbsp;</td>
    </tr>
  </table>

  <br/>
  <br/>
   </form>
  <?php
   	   if(isset($_POST['Delete']))
{
	  
	  $Competition_Id=$_POST['Competition_Id'];
   $School_Id=$_POST['School_Id'];
	  $Date=$_POST['Date'];
 if( $Competition_Id=="Select One"||$School_Id=="Select One"||$Date=="Select One")
	   {
		   $_SESSION['errorin']="Please select the Competition_Id,School_Id and Date!";
   
	   } 
	  if($Competition_Id!="Select One"&&$School_Id!="Select One"&&$Date!="Select One")
	   {

    echo '<table width="458" border="0">';
	while($row=mysql_fetch_array($result))
  { 
$Competition_Id=$row['Competition_Id'];
   $School_Id=$row['School_Id'];
 $Competition_Name=$row['Competition_Name'];
    $No_Of_Students=$row['No_Of_Students'];
    $No_Of_Teachers=$row['No_Of_Teachers'];
    $Result=$row['Result'];
    $Date=$row['Date'];
    $Scope=$row['Scope'];
   $Winner=$row['Winner'];
    
       echo '<tr>';
        echo '<th width="200" height="44" scope="row">';
		echo "Programme Name:";
		echo '</th>';
        echo '<td width="144">';
		echo $Competition_Name;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number of students:";
		echo '</th>';
        echo '<td>';
		echo $No_Of_Students;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number of teachers in training:";
		echo '</th>';
        echo '<td>';
		echo $No_Of_Teachers;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number of trained teachers :";
		echo '</th>';
       echo '<td>';
	   echo $Result;
	   echo '</td>';
      echo '</tr>';
        echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Availability of teachers guides:"; 
		echo '</th>';
        echo '<td>';
		echo $Scope;
		echo '</td>';
      echo '</tr>';
	   echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Availability of teachers guides:"; 
		echo '</th>';
        echo '<td>';
		echo $Winner;
		echo '</td>';
      echo '</tr>';
	 
   }
    echo '</table>';
	
	
	}	
}
    ?>
	
	
</div>
</div>

<div class="rightmenu"> 
<h1>COMPETITIONS</h1><br />
<table width="220" border="0">
  <tr>
    <td width="210" height="41"><a href="RegCom.php">Add New Competition</a></td>
   

  </tr>
  <tr>
    <td height="41"><a href="SeachCom.php">Search a Competition</a></td>
    
    
  </tr>
  <tr>
    <td height="41"><a href="SearchComSch.php">Search Competitions for a school</a></td>

    
  </tr>
  <tr>
    <td height="41"><a href="UpdateComSch.php">Update a Competition of a School</a></td>
 
    
  </tr>
  <tr>
    <td height="41"><a href="DelCom.php">Delete a Competition of a School</a></td>
    
    
  </tr>
  <tr>
    <td height="41"><a href="viewall.php">View All</a></td>
   

  </tr>
</table></div>
 
 <div style="clear: both;"> </div>


<div id="footer"><table width="1236" height="38" border="0">
    <tr>
      <td width="904" height="34">Schools Managemrnt System &copy; 2012 </td>
      <td width="50"><strong><a href="#" class="active">Home</a><a href="#"></a></strong>|</td>
      <td width="80"><strong><a href="#">Contact us</a></strong>|</td>
      <td width="40"><a href="http//www.facebook.com"><img src="../images/facebook1.png" width="38" height="38"/></a></td>
      <td width="38"><a href="http//twitter.com"><img src="../Images/twitter.png" width="38" height="38"/></a></td>
      <td width="36"><a href="http//www.google.lk"><img src="../Images/google.png" width="38" height="38"/></a><a href=""http="http"//www.yahoo.com""></a></td>
      <td width="58"><a href=""http="http"//www.yahoo.com""><img src="../Images/yahoo.png" alt="" width="38" height="38"/></a></td>
    </tr>
  </table>
 
</div>
</div>
<?php
	  }
?>
</body>
</html>